Machine learning comes in two varieties:
\[(X_1, y_1), (X_2, y_2), ..., (X_n, y_n)\]
Can we learn \(f\) by optimising \(\theta\) on training data?
\[\begin{equation} H_i = a + b S_i + \epsilon_i \end{equation}\]
where \(H_i\) is the house price; \(S_i\) is the size in square feet; and \(\epsilon_i\) is an error term.
Choose a model to minimise the sum of squared errors, that is:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} \epsilon_i^2 \end{equation}\]
which is the same as choosing values of \(a\) and \(b\) to minimise:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} (H_i - (a + b S_i))^2 \end{equation}\]
Least absolute deviation loss:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} |\epsilon_i| \end{equation}\]
Quartic power loss:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} \epsilon_i^4 \end{equation}\]
Suppose we want to minimise a least-squares loss function:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} (H_i - (a + b S_i))^2 \end{equation}\]
Choose \(a\) and \(b\) to minimise this loss \(\implies\) differentiate!
determine \(\hat{a}\) and \(\hat{b}\) as those minimising \(L\):
\[\begin{align} \frac{\partial L}{\partial a} &= -\frac{2}{K}\sum_{i=1}^{K} (H_i - (a + b S_i)) = 0\\ \frac{\partial L}{\partial b} &= -\frac{2}{K}\sum_{i=1}^{K} S_i (H_i - (a + b S_i)) = 0 \end{align}\]
For general loss functions, no solution exists. That is, usually equations like:
\[\begin{align} -\frac{2}{K}\sum_{i=1}^{K} (H_i - (a + b S_i)) &= 0\\ -\frac{2}{K}\sum_{i=1}^{K} S_i (H_i - (a + b S_i)) &= 0 \end{align}\]
have no solution. (Here, they actually do.)
Instead of solving equations directly, we use gradient descent optimisation
\[\begin{align} a &= a - \eta \frac{\partial L}{\partial a}\\ b &= b - \eta \frac{\partial L}{\partial b} \end{align}\]
until \(a\) and \(b\) no longer change. \(\eta\) is the learning rate
\[\begin{equation} H_i = a + b S_i + c S_i^2 + \epsilon_i \end{equation}\]
What does this model look like?
Least-squares loss function:
\[\begin{equation} L = \frac{1}{K} \sum_{i=1}^{K} (H_i - (a + b S_i + c S_i^2))^2 \end{equation}\]
\[\begin{align} a &= a - \eta \frac{\partial L}{\partial a}\\ b &= b - \eta \frac{\partial L}{\partial b}\\ c &= c - \eta \frac{\partial L}{\partial c} \end{align}\]
\[\begin{equation} H_i = a + b S_i + c S_i^2 + d S_i^3 + ... \epsilon_i \end{equation}\]
Hold out a separate validation set to test model predictions on
No:
All available on SOLO:
Coursera: